<extend name="Base/common"/>
<block name="style">
    <style type="text/css">

    </style>
</block>
<block name="body">
<div class="wraper">
<div class="content" style="margin-top:-13%;">
<php>    $PROVINCE = C('PROVINCE');</php>
<form class="formtijiao" action="" method="post">

    <h3 class="info-tit green"><i class="app-iconfont">&#xe6bf;</i>个人信息</h3>
    <!-- <div class="weui-cells__title">个人信息</div> -->
    <div class="register-kk">
        
        <div class="weui-cell reside_province_select">
            <div class="weui-cell__hd"><label class="weui-label">居住省份：</label></div>
            <div class="weui-cell__bd">
                <div class="weui-cell weui-cell_select">
                    <input type="hidden" value="{$info.reside_province}" class="reside_province" name="member[reside_province]" >
                    <div class="weui-cell__bd reside_province_text">
                        <empty name="info['reside_province']">
                            请选择
                            <else/>
                            {$PROVINCE[$info[reside_province]]}
                        </empty>

                    </div>
                </div>
            </div>
        </div>
        <div class="weui-cell reside_area_select">
            <div class="weui-cell__hd"><label class="weui-label">居住区域：</label></div>
            <div class="weui-cell__bd">
                <div class="weui-cell weui-cell_select">
                    <input type="hidden" value="{$info.reside_area}" class="reside_area" name="member[reside_area]" >
                    <div class="weui-cell__bd reside_area_text">
                        <empty name="info['reside_area']">
                            请选择
                            <else/>
                            <php>
                                $data   =   D('Area')->get_addr($info['reside_area']);echo ($data);
                            </php>
                        </empty>
                    </div>
                </div>
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">现居住地址：</label></div>
            <div class="weui-cell__bd">
                <input class="weui-input" placeholder="请输入详细地址" type="text" value="{$info.reside_addr}" name="member[reside_addr]">
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">居住时长：</label></div>
            <div class="weui-cell__bd">
                <div class="weui-cell weui-cell_select">
                    <div class="weui-cell__bd">
                        <php>
                            $MEMBER_RESIDE_DURATION = C('MEMBER_RESIDE_DURATION');
                            
                        </php>
                        <select class="weui-select" name="member[reside_duration]">
                            <option  value="0">请选择</option>
                            <foreach name="MEMBER_RESIDE_DURATION" key="key" item="val">
                                <option <eq name="key" value="$info['reside_duration']">selected="selected"</eq> value="{$key}">{$val}</option>
                            </foreach>
                        </select>
                       
                    </div>
                </div>
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label"> 婚姻状态：</label></div>
            <div class="weui-cell__bd">
                <div class="weui-cell weui-cell_select">
                    <div class="weui-cell__bd">
                        <php>
                            $MEMBER_MARITAL_STATUS = C('MEMBER_MARITAL_STATUS');
                        </php>
                        <select class="weui-select" name="member[marital_status]">
                            <option value="0">请选择</option>
                            <foreach name="MEMBER_MARITAL_STATUS" key="key" item="val">
                                <option <eq name="key" value="$info['marital_status']">selected="selected"</eq> value="{$key}">{$val}</option>
                            </foreach>
                        </select>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <h3 class="info-tit blue2 mg-t-4 " ><i class="app-iconfont">&#xe60e;</i> 职业信息</h3>
 

    <!-- <div class="weui-cells__title">职业信息</div> -->
    <div class="register-kk">
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">单位名称：</label></div>
            <div class="weui-cell__bd">
                <input class="weui-input" placeholder="请输入单位名称" value="{$info.unitname}" type="text" name="member[unitname]">
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">职业类型：</label></div>
            <div class="weui-cell__bd">
                <div class="weui-cell weui-cell_select">
                    <div class="weui-cell__bd">
                        <php>
                            $MEMBER_CAREER_TYPE = C('MEMBER_CAREER_TYPE');
                        </php>
                        <select class="weui-select" name="member[career_type]">
                            <option value="0">请选择</option>
                            <foreach name="MEMBER_CAREER_TYPE" key="key" item="val">
                                <option <eq name="key" value="$info['career_type']">selected="selected"</eq> value="{$key}">{$val}</option>
                            </foreach>
                        </select>
                    </div>
                </div>
            </div>
        </div>



        <div class="weui-cell unit_province_select">
            <div class="weui-cell__hd"><label class="weui-label">单位省份：</label></div>
            <div class="weui-cell__bd">
                <div class="weui-cell weui-cell_select">
                    <input type="hidden" value="{$info.unit_province}" class="unit_province" name="member[unit_province]" >
                    <div class="weui-cell__bd unit_province_text">
                        <empty name="info['unit_province']">
                            请选择
                            <else/>
                            {$PROVINCE[$info[unit_province]]}
                        </empty>

                    </div>
                </div>
            </div>
        </div>
        <div class="weui-cell unit_area_select">
            <div class="weui-cell__hd"><label class="weui-label">单位城市：</label></div>

            <div class="weui-cell__bd">
                <div class="weui-cell weui-cell_select">
                    <input type="hidden" value="{$info.unit_area}" class="unit_area" name="member[unit_area]" >
                    <div class="weui-cell__bd unit_area_text">
                        <empty name="info['unit_area']">
                            请选择
                            <else/>
                            <php>
                                $data   =   D('Area')->get_addr($info['unit_area']);echo ($data);
                            </php>
                        </empty>
                    </div>
                </div>
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">单位地址：</label></div>
            <div class="weui-cell__bd">
                <input class="weui-input" value="{$info.unit_addr}" name="member[unit_addr]" placeholder="请输入单位地址" type="text">
            </div>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">单位电话：</label></div>
            <div class="weui-cell__bd">
                <input class="weui-input dwdh" value="{$info.unit_phone}" name="member[unit_phone]" placeholder="请输入单位电话(07711234567)" type="tel">
            </div>
        </div>
    </div>

    <h3 class="info-tit red mg-t-4"><i class="app-iconfont">&#xe600;</i> 社会关系</h3>
    <!-- <div class="weui-cells__title">社会关系</div> -->
    <div class="register-kk">
        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label"> 直系亲属：</label></div>
            <div class="weui-cell__bd">
                <div class="weui-cell weui-cell_select">
                    <div class="weui-cell__bd">
                        <php>
                            $MEMBER_RELATI_ONSHIP = C('MEMBER_RELATI_ONSHIP');
                            $relati = 1;
                            if(!empty($info['child_status'])){
                            $relati = $info['child_status'];
                            }
                        </php>
                        <select class="weui-select relati_onship" name="member[relati_onship]">
                            <foreach name="MEMBER_RELATI_ONSHIP" key="key" item="val">
                                <option class="option{$key}"  <eq name="key" value="$info['child_status']">selected="selected"</eq> value="{$key}">{$val}</option>
                            </foreach>
                        </select>
                    </div>
                </div>
            </div>
        </div>
        <div class="weui-cell">
        <div class="weui-cell__hd"><label class="weui-label">姓名：</label></div>
        <div class="weui-cell__bd">
            <input class="weui-input relati_name" placeholder="请输入{$MEMBER_RELATI_ONSHIP[$relati]}的姓名" value="{$info.relati_name}" type="text" name="member[relati_name]">
        </div>
    </div>

        <div class="weui-cell">
            <div class="weui-cell__hd"><label class="weui-label">手机号码：</label></div>
            <div class="weui-cell__bd">
                <input class="weui-input relati_number" name="member[relati_number]" value="{$info.relati_number}" placeholder="请输入{$MEMBER_RELATI_ONSHIP[$relati]}的手机号码" type="tel">
            </div>
        </div>
        <div class="weui-cell">
        <div class="weui-cell__hd"><label class="weui-label"> 社会关系：</label></div>
        <div class="weui-cell__bd">
            <div class="weui-cell weui-cell_select">
                <div class="weui-cell__bd">
                    <php>
                        $MEMBER_SOCIAL_RELATIONS = C('MEMBER_SOCIAL_RELATIONS');
                            $social = 1;
                        if(!empty($info['child_status'])){
                            $social = $info['child_status'];
                        }
                    </php>
                    <select class="weui-select social_relations" name="member[social_relations]">
                        <foreach name="MEMBER_SOCIAL_RELATIONS" key="key" item="val">
                            <option class="option{$key}" <eq name="key" value="$info['child_status']">selected="selected"</eq> value="{$key}">{$val}</option>
                        </foreach>
                    </select>
                </div>
            </div>
        </div>
    </div>
    <div class="weui-cell">
        <div class="weui-cell__hd"><label class="weui-label">姓名：</label></div>
        <div class="weui-cell__bd">
            <input class="weui-input social_name" placeholder="请输入{$MEMBER_SOCIAL_RELATIONS[$social]}的姓名" value="{$info.social_name}" type="text" name="member[social_name]">
        </div>
    </div>
    <div class="weui-cell">
        <div class="weui-cell__hd"><label class="weui-label">手机号码：</label></div>
        <div class="weui-cell__bd">
            <input class="weui-input social_number" placeholder="请输入{$MEMBER_SOCIAL_RELATIONS[$social]}的手机号码" value="{$info.social_number}" type="tel" name="member[social_number]">
        </div>
    </div>


    </div>
                    <input type="button"  value="确认提交" class="login-btn" />
    
</form>

<php>
    $province = array();
    foreach($PROVINCE as $k=>$v){
     $province[]=['label'=>$v,'value'=>$k];
    }
</php>
</div>
</div>
</block>
<block name="script">
    <script type="text/javascript">
        (function(){
            $('.relati_onship').change(function(){
               var val  = $(this).val();
               var html = $(this).find('.option'+val).text();
                html = '请输入'+html+'的手机号码';
                $('.relati_number').attr('placeholder',html);
            });
            $('.social_relations').change(function(){
                var val  = $(this).val();
                var html = $(this).find('.option'+val).text();
                html = '请输入'+html+'的手机号码';
                $('.social_number').attr('placeholder',html);
            });

            $('.relati_number').change(function(){
                var val  = $(this).val();
                checkMobile(val);
            });
            $('.social_number').change(function(){
                var val  = $(this).val();
                checkMobile(val);
            });
            $('.dwdh').change(function(){
                var val  = $(this).val();
                if(!(/^0\d{10}$/.test(val))){ 
                   popup.alert("单位号码输入有误！"); 
                   return false; 
                }
            });



        })();

        function checkMobile(sMobile){ 
         if(!(/^1[3|4|5|7|8][0-9]\d{8}$/.test(sMobile))){ 
          popup.alert("不是完整的11位手机号或者正确的手机号前3位"); 
          return false; 
         }
        } 
    </script>
    <script >
        var province,Url;
        province = <php>echo json_encode($province)</php>;
        Url      = "{:U('Ajax/getRegion')}";
        Zepto(function($){
            //居住省份选择
            $('.reside_province_select').on('click', function () {
                weui.picker(province, {
                    onChange: function (result) {
                    },
                    onConfirm: function (result) {
                        for (var i=0;i<province.length;i++){
                            if(province[i].value==result){
                                $('.reside_province_text').html(province[i].label);
                                $('.reside_province').val(result);
                            }
                        }
                    }
                });
            });
            //省份未选择时无法选择居住区域
            $('.reside_area_select').on('click', function () {
                var reside_province = $('.reside_province').val();
                if(reside_province=='' || reside_province==0){
                    popup.alert('请选择居住省份');return false;
                }
                AjaxGet(Url,{pid:reside_province},function(data){

                    weui.picker(data, {
                        onChange: function (result) {
                        },
                        onConfirm: function (result) {
                            for (var i=0;i<data.length;i++){
                                if(data[i].value==result){
                                    $('.reside_area_text').html(data[i].label);
                                    $('.reside_area').val(result);
                                }
                            }
                        }
                    });
                });
            });
            //单位省份
            $('.unit_province_select').on('click', function () {
                weui.picker(province, {
                    onChange: function (result) {
                    },
                    onConfirm: function (result) {
                        for (var i=0;i<province.length;i++){
                            if(province[i].value==result){
                                $('.unit_province_text').html(province[i].label);
                                $('.unit_province').val(result);
                            }
                        }
                    }
                });
            });
            //单位区域
            $('.unit_area_select').on('click', function () {
                var unit_province = $('.unit_province').val();
                if(unit_province=='' || unit_province==0){
                    popup.alert('请选择单位省份');return false;
                }
                AjaxGet(Url,{pid:unit_province},function(data){
                    weui.picker(data, {
                        onChange: function (result) {
                        },
                        onConfirm: function (result) {
                            for (var i=0;i<data.length;i++){
                                if(data[i].value==result){
                                    $('.unit_area_text').html(data[i].label);
                                    $('.unit_area').val(result);
                                }
                            }
                        }
                    });
                });
            });

           
            $('.login-btn').click(function(){
                var data =  $('form').serializeArray();
                $.ajax({
                    type:'post',
                    url:"{:U('Member/userinfo')}",
                    data:data,
                    // dataType:'json',
                    beforeSend:function(XMLHttpRequest){
                        popup.loading('正在提交中');
                        //ShowLoading();正在提交中
                    },
                    success:function(m){
                        popup.alert(m)
                        setTimeout(function(){
                            location.href="{:U('Index/index')}"
                        },1500);
                        
                        // popup.alert(m['info']);
                        // location.href=m['url']
                    },
                    complete:function(XMLHttpRequest,textStatus){
                       popup.noloading();
                    },
                   
            });
           
            }) ;
        });

    

    </script>

    
</block>